package deng.camel.examples;

import org.apache.camel.Body;
import org.apache.camel.Header;

import deng.camel.core.CamelRide;


public class BeanDemo extends CamelRide {
	
	public static void main(String[] args) {
		new BeanDemo().start();
	}
	
	@Override
	public void configure() throws Exception {
        from("direct:entryPoint").
        to("bean:beanDemo?method=process").
        process(getShutdownLatchProcessor());
		
	}
	
	@Override
	public void beforeCamelStart() {
		registerBean("beanDemo", this);
	}
	
	@Override
	public void afterCamelStart() {
		sendMessage("direct:entryPoint", "Camel Rocks!", "sender", "Zemian", "myId", 12345);
	}
	
//	/** This take precedence over TypeConversion method below! */
//	public void process(Exchange exchange) {
//		Message msg = exchange.getIn();
//		logger.info("Processing exchange message=" + msg);
//	}
	
	public String process(@Body String body, @Header("sender") String sender) {
		logger.info("Processing string message=" + body + ", from=" + sender);
		return body.toUpperCase();
	}
	
}
